home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr44 / frasrc19.zip / TGAVIEW.C < prev    next >
C/C++ Source or Header  |  1994-11-28  |  1KB  |  61 lines

  1.  
  2. /* Routine to decode Targa 16 bit RGB file
  3.    */
  4.  
  5. /* 16 bit .tga files were generated for continuous potential "potfile"s
  6.    from version 9.? thru version 14.  Replaced by double row gif type
  7.    file (.pot) in version 15.  Delete this code after a few more revs.
  8. */
  9.  
  10. #include <stdio.h>
  11. #include "fractint.h"
  12. #include "targa_lc.h"
  13. #include "prototyp.h"
  14.  
  15. static FILE *fptarga = NULL;        /* FILE pointer       */
  16.  
  17. /* Main entry decoder */
  18. tgaview()
  19. {
  20.    int i;
  21.    int cs;
  22.    unsigned int width;
  23.    struct fractal_info info;
  24.  
  25.    if((fptarga = t16_open(readname, (int *)&width, (int *)&height, &cs, (U8 *)&info))==NULL)
  26.       return(-1);
  27.  
  28.    rowcount = 0;
  29.    for (i=0; i<(int)height; ++i)
  30.    {
  31.        t16_getline(fptarga, width, (U16 *)boxx);
  32.        if ((*outln)((void *)boxx,width))
  33.        {
  34.       fclose(fptarga);
  35.       fptarga = NULL;
  36.       return(-1);
  37.        }
  38.        if (keypressed())
  39.        {
  40.       fclose(fptarga);
  41.       fptarga = NULL;
  42.       return(-1);
  43.        }
  44.    }
  45.    fclose(fptarga);
  46.    fptarga = NULL;
  47.    return(0);
  48. }
  49.  
  50. /* Outline function for 16 bit data with 8 bit fudge */
  51. outlin16(BYTE *buffer,int linelen)
  52. {
  53.     int i;
  54.     U16 *buf;
  55.     buf = (U16 *)buffer;
  56.     for(i=0;i<linelen;i++)
  57.        putcolor(i,rowcount,buf[i]>>8); 
  58.     rowcount++;
  59.     return(0);
  60. }
  61.